using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Contact_Manager
{
    public partial class SettingForm : Form
    {
        public SettingForm()
        {
            InitializeComponent();
        }

        private void Setting_Load(object sender, EventArgs e)
        {
            this.txtDelimit.Text = Properties.Settings.Default.Delimiters;

            this.KeyPreview = true;
            this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Setting_KeyDown);                  
        }

        private void Setting_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Escape) this.Close();
            else if (e.KeyData == Keys.Enter) this.SaveSettings(); 
        }

        private void SaveSettings()
        {
            Properties.Settings.Default.Delimiters = txtDelimit.Text;
            Properties.Settings.Default.Save();
            this.Close();            
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            this.SaveSettings();
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            this.txtDelimit.Text = ",";
        }

    }
}